const path = require('path')
const defaultSettings = require('./src/settings.js')

const resolve = (dir) => path.join(__dirname, dir)

const name = defaultSettings.title || 'base-web' // 标题

module.exports = {
  devServer: {
    port: 8080,
    disableHostCheck: true
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },
  chainWebpack: (config) => {
    config.module
      .rule('swf')
      .test(/\.swf$/)
      .use('url-loader')
      .loader('url-loader')
      .options({
        limit: 10000
      })

    // set svg-sprite-loader
    config.module.rules.delete('svg') // 重点:删除默认配置中处理svg
    config.module
      .rule('svg-sprite-loader')
      .test(/\.svg$/)
      .include
      .add(resolve('src/icons')) // 处理svg目录
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
  }
}
